package com.ruoyi.web.factory;

import com.ruoyi.web.enums.ArticleTypeEnum;
import com.ruoyi.web.service.StrategyService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @description: 策略工厂
 * @author: zhengxiong.jiang
 * @createDate: 2023/11/16
 * @version: 1.0
 */
@Service
public class StrategyFactory {

    private static final Map<ArticleTypeEnum, StrategyService> strategyServiceMap = new HashMap<>();

    public void register(ArticleTypeEnum type,StrategyService strategyService){
        strategyServiceMap.put(type,strategyService);
    }

    public StrategyService getStrategyService(ArticleTypeEnum type){
        return strategyServiceMap.get(type);
    }

    public Map<ArticleTypeEnum, StrategyService> getStrategyServiceMap(){
        return strategyServiceMap;
    }

}
